import { createRouter, createWebHashHistory,RouteRecordRaw } from 'vue-router'
// import type {RouteType} from 'vue-router'
// import HomeView from '../views/HomeView.vue'
import HomeView from '@/views/home/Index.vue'
import KindView from '@/views/kind/Index.vue'
import CartView from '@/views/cart/Index.vue'
import UserView from '@/views/user/Index.vue'
// interface iItem {
//   path: string;
//   name: string;
//   component: any,
//   children?: Array<iItem>,
//   meta?: {hidden: boolean},
//   redirect?: any
// }

const routes:Array<RouteRecordRaw> = [
  {
    path: '/',
    // redirect 配置路由重定向
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView
  },{
    path: '/kind',
    name: 'kind',
    component: KindView
  },{
    path: '/cart',
    name: 'cart',
    component: CartView
  },{
    path: '/user',
    name: 'user',
    component: UserView
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      // 配置路由的元信息
      hidden: true
    },
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/login/Index.vue')
  },
  {
    path: '/register',
    name: 'register',
    meta: {
      // 配置路由的元信息
      hidden: true
    },
    component: () => import('../views/register/Index.vue'),
    children: [
      {
        path: 'step1',
        name: 'step1',
        component: () => import('../views/register/step1.vue'),
      },
      {
        path: 'step2',
        name: 'step2',
        component: () => import('../views/register/step2.vue'),
      },
      {
        path: 'step3',
        name: 'step3',
        component: () => import('../views/register/step3.vue'),
      }
    ]
  },{
    // path: '/detail/:proid',
    path: '/detail',
    name: 'detail',
    meta: {
      // 配置路由的元信息
      hidden: true
    },
    component: () => import('../views/detail/Index.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes
})

export default router
